/**
 * Copyright 2002-2006 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package opentss;

import java.io.IOException;
import java.io.InputStream;

/**
 * Reader on top of stream.
 * 
 * @author <a href="mailto:max.h.chen@hotmail.com">Max Chen</a>
 */
public class StreamReader implements Reader {
	
	private InputStream input;
	
	public StreamReader(InputStream input) {
		this.input = input;
	}

	public byte readByte() throws IOException {
		return StreamUtil.readByte(input);
	}
	
	public boolean readBoolean() throws IOException {
		return StreamUtil.readBoolean(input);
	}
	
	public char readChar() throws IOException {
		return StreamUtil.readChar(input);
	}
	
	public short readShort() throws IOException {
		return StreamUtil.readShort(input);
	}
	
	public int readInt() throws IOException {
		return StreamUtil.readInt(input);
	}
	
	public long readLong() throws IOException {
		return StreamUtil.readLong(input);
	}
	
	public float readFloat() throws IOException {
		return StreamUtil.readFloat(input);
	}
	
	public double readDouble() throws IOException {
		return StreamUtil.readDouble(input);
	}
	
	public String readUTF() throws IOException {
		return StreamUtil.readUTF(input);
	}
	
	public int read(byte[] bytes, int offset, int length) throws IOException {
		return StreamUtil.readFully(input, bytes, offset, length);
	}

	public void close() {
		StreamUtil.close(input);
	}
}
